import datetime
from typing import Optional

from pydantic import BaseModel, ConfigDict, Field
from pydantic.alias_generators import to_camel

from module_admin.annotation.pydantic_annotation import as_query


class FutureAccountModel(BaseModel):
    """
    期货账户表对应pydantic模型
    """

    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    id: Optional[int] = Field(default=None, description='账户id')
    account_code: Optional[str] = Field(default=None, description='账户代码')
    account_name: Optional[str] = Field(default=None, description='账户名称')
    futures_company: Optional[str] = Field(default=None, description='期货公司')
    settlement_account: Optional[str] = Field(default=None, description='结算单账号')
    settlement_password: Optional[str] = Field(default=None, description='结算单密码')
    trade_username: Optional[str] = Field(default=None, description='交易用户名')
    trade_password: Optional[str] = Field(default=None, description='交易密码')
    broker_code: Optional[str] = Field(default=None, description='经纪商代码')
    trade_server: Optional[str] = Field(default=None, description='交易服务器')
    market_server: Optional[str] = Field(default=None, description='行情服务器')
    product_name: Optional[str] = Field(default=None, description='产品名称')
    auth_code: Optional[str] = Field(default=None, description='授权编码')
    product_info: Optional[str] = Field(default=None, description='产品信息')
    create_time: Optional[datetime.datetime] = Field(default=None, description='创建时间')
    update_time: Optional[datetime.datetime] = Field(default=None, description='更新时间')


@as_query
class FutureAccountQueryModel(FutureAccountModel):
    """
    期货账户管理不分页查询模型
    """
    pass


@as_query
class FutureAccountPageQueryModel(FutureAccountQueryModel):
    """
    期货账户管理分页查询模型
    """

    account_code: Optional[str] = Field(default=None, description='账户代码')
    page_num: int = Field(default=1, description='当前页码')
    page_size: int = Field(default=10, description='每页记录数')


class DeleteFutureAccountModel(BaseModel):
    """
    删除期货账户模型
    """

    ids: Optional[list[int]] = Field(default=None, description='账户ID列表')
    account_names: Optional[list[str]] = Field(default=None, description='账户名称列表')